
package com.joysuch.wwyt.risk.controller;

import cn.afterturn.easypoi.word.WordExportUtil;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.core.common.util.PageDataUtils;
import com.joysuch.wwyt.risk.bean.RiskEvaluationRepoListBean;
import com.joysuch.wwyt.risk.bean.RiskEvaluationRepoListBean.Search;
import com.joysuch.wwyt.risk.enums.EvaluationStates;
import com.joysuch.wwyt.risk.enums.EvaluationTypes;
import com.joysuch.wwyt.risk.service.RiskEvaluationRepoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.joysuch.wwyt.core.common.ajax.ResultBean.SUCCESS_CODE;

@RestController
@RequestMapping("/risk/evaluation")
public class RiskEvaluationRepoController {

    private static final Logger logger = LoggerFactory.getLogger(RiskEvaluationRepoController.class);

    @Autowired
    private RiskEvaluationRepoService riskEvaluationRepoService;

    @RequestMapping("scl-page")
    public Object sclPage(Pageable page, Search condition) {
        page = PageDataUtils.addOrderByDesc(page, "code");
        Page<RiskEvaluationRepoListBean> data = riskEvaluationRepoService.findByPage(page, condition,
                EvaluationTypes.SCL, EvaluationStates.EFFECTIVE);
        return ResultBean.pageData(data);
    }

    @RequestMapping("jha-page")
    public Object jhaPage(Pageable page, Search condition) {
        page = PageDataUtils.addOrderByDesc(page, "code");
        Page<RiskEvaluationRepoListBean> data = riskEvaluationRepoService.findByPage(page, condition,
                EvaluationTypes.JHA, EvaluationStates.EFFECTIVE);
        return ResultBean.pageData(data);
    }

}
